<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="fm" method="post" action="/ajax/">{% csrf_token %}
    {{ obj.as_p }}
    <input type="submit" value="ajaxsubmit" id="btn">
    </form>
    <script src="/static/jquery-3.3.1.js"></script>
    <script>
        $(function(){
            $('#btn').click(function () {
                $.ajax({
                    url: '/ajax/',
                    type: 'POST',
                    data: $('#fm').serialize(),
                    success:function (arg) {
                        // arg: 状态，错误信息
                        console.log(arg,123);
                        if(arg.status == '钱'){
                            window.location.href = 'https://www.baidu.com';
                        }else{
                            console.log(arg['msg']);
                        }
                    }
                })

            })
        })
    </script>
</body>
</html>